package com.samphanie.auiu.http

import android.text.TextUtils
import com.samphanie.auiu.biz.account.AccountManager
import com.samphanie.auiu.common.utils.SPUtil
import com.samphanie.auiu.library.log.AuiuLog
import com.samphanie.auiu.library.restful.AuiuInterceptor

/**
 * @author Dries
 **/
class BizInterceptor: AuiuInterceptor {
    override fun intercept(chain: AuiuInterceptor.Chain): Boolean {
        if (chain.isRequestPeriod) {
            val request = chain.request()

            val token = AccountManager.getAuthorization()

            // val boardingPass = SPUtil.getString("boarding-pass")?: ""
            // request.addHeader("boarding-pass", boardingPass)
            request.addHeader("Authorization", token)
        } else if (chain.response() != null) {
            AuiuLog.dt("BizInterceptor", chain.request().endPointUrl())
            AuiuLog.dt("BizInterceptor", chain.response()!!.rawData)
        }

        return false
    }
}